package cn.com.gof.create.prototype;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.sql.Date;

/**
 * <p>Title: Client</p>  
 * <p>Description: </p>  
 * @author WangJun
 * @date 2018年9月6日 下午2:33:24
 */
public class Client2 {
	public static void main(String[] args) throws Exception {
		
		Date date = new Date(1234567890L);
		Sheep s1 = new Sheep("haha", date);
		
		ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
		ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
		objectOutputStream.writeObject(s1);
		byte[] byteArray = byteArrayOutputStream.toByteArray();
		ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
		ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
		Sheep s2 = (Sheep) objectInputStream.readObject();
		System.out.println(s1.getName());
		System.out.println(s1.getBirthDate());
		date = new Date(132456789L);
		s1.setBirthDate(new Date(132L));
		s1.setName("enen");
		System.out.println(s2.getName());
		System.out.println(s2.getBirthDate());
	}
}
